package com.chixing.controller;

import com.chixing.pojo.SecKill;
import com.chixing.service.SeckillService;
import com.chixing.util.ServerResult;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class SecKillController implements InitializingBean {

  @Autowired
  private SeckillService seckillService;

  @GetMapping("/secKill")
  @ResponseBody
  public ServerResult getSecKillPro(@RequestParam("startTime") String startTime) {

    System.out.println("controller---startTime" + startTime);
    ServerResult secKillPro = seckillService.getSecKillPro(startTime);

    return secKillPro;

  }


  /**
   * 在加载系统的时候将商品的库存信息存放到redis。
   * afterPropertiesSet方法,初始化bean的时候执行，可以针对某个具体的bean进行配置。。
   *
   */
  @Override
  public void afterPropertiesSet() {

    List<SecKill> allSecKillPro = seckillService.getAllSecKillPro();




  }
}
